package com.nmc.core.dto.search;

import java.util.Date;

import org.hibernate.Criteria;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;

public class WorkerSearchCriteria extends SearchCriteria {

	private String firstName = null; 
	
	private String lastName=null;
	
	private Date joiningDate=null;
	
	private String gender = null;
	
	public String getFirstName() {
		return firstName;
	}
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	public String getLastName() {
		return lastName;
	}
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	public Date getJoiningDate() {
		return joiningDate;
	}
	public void setJoiningDate(Date joiningDate) {
		this.joiningDate = joiningDate;
	}
	
	public String getGender() {
		return gender;
	}
	
	public void setGender(String gender) {
		this.gender = gender;
	}

	
	public void addRestrictions(Criteria criteria) {
		// TODO Auto-generated method stub
		super.addRestrictions(criteria);
		if(firstName != null && !"".equals(firstName)) {
			criteria.add(Restrictions.ilike("firstName", firstName, MatchMode.ANYWHERE));
		}
		
		if(lastName != null && !"".equals(lastName)) {
			criteria.add(Restrictions.ilike("lastName", lastName, MatchMode.ANYWHERE));
		}
		
		if(gender != null && !"".equals(gender)) {
			criteria.add(Restrictions.ilike("gender", gender, MatchMode.EXACT));
		}
	}
	
	
	
}
